<template>
	<view class="page">
		<view class="searchBox">
			<view class="inputBox">
				<view class="inputRow" style=""  >
					<view class="label">
						班级:
					</view>
					<view :class="selectLabel ? 'val' : 'val'" @click="selectListShow=true">
						{{selectLabel ? selectLabel : '初二(1)班' }}
					</view>
				</view>
				<view class="inputRow" style="" >
					<view class="label">
						姓名:
					</view>
					<view  class="val" >
						<text>胡子轩</text>
						<!-- <u-input v-model="params.personName" placeholder="请输入姓名"></u-input> -->
					</view>
				</view>
				<view class="inputRow">
					<view class="label">
						日期:
					</view>
					<view :class="params.accessDate_begin ? 'val' : 'emty'" @click="accessDate_beginShow=true">
						{{params.accessDate_begin ? params.accessDate_begin : '请选择' }}
					</view>
				</view>
			</view>
			<view class="btnBox">
				<view class="btn"  @click="goSearch">
					搜索
				</view>
			</view>
		</view>
		
		<view class="contentBox">
			<view class="left itemBox">
				<view class="leftRow" v-for="(item,index) in rightActionArr" :key="index">
					<u--image :showLoading="true" :src="item.img" width="90rpx" height="90rpx"></u--image>
					<view class="text">
						{{item.action}}
					</view>
				</view>
			</view>
			<view class="right itemBox">
				<view class="rightRow" v-for="(item,index) in leftActionArr" :key="index">
					<view class="text">
						{{item.action}}
					</view>
					<u--image :showLoading="true" :src="item.img" width="90rpx" height="90rpx"></u--image>
					
				</view>
			</view>
		</view>
			
	
		<u-datetime-picker
		    :show="startDateShow" ref="datetimePicker" v-model="startDate" 
		    mode="dateTime"  @cancel="startDateShow=false" @confirm="startDateConfirm"
		       ></u-datetime-picker>
		<u-datetime-picker
			:show="endDateShow" ref="datetimePicker" v-model="endDate" 
			mode="dateTime"  @cancel="endDateShow=false" @confirm="endDateConfirm"
	       ></u-datetime-picker>
		<u-picker :show="selectListShow" :columns="selectList" keyName="label"
			@cancel="selectListShow = false"></u-picker>
	</view>
</template>

<script>
	import {acTemporaryGeneralAddApi} from '@/common/api/commonApi/safeApi.js'
	import scollerXTabel from '@/components/scollerXTabel.vue'
	export default {
		data() {
			return {
				list:[],
				params:{
					createBy: uni.getStorageSync('selectInfoAccount').name,
					createId: uni.getStorageSync('selectInfoAccount').id,
					personId :'',
					startDate : '',
					endDate : '',
					generalClassify: 1,
				},
				startDate: Number(new Date()),
				endDate: Number(new Date()),
				startDateShow : false,
				endDateShow : false,
				total : 0,
				isTeacher: 1,
				selectList : [
					[
						{
							label : 'PC机',
							val: 1
						},
						{
							label : '移动端',
							val: 2
						},
						{
							label : '充值机',
							val: 3
						},
						{
							label : 'P0S',
							val: 4
						},
						
					]
				],
				selectLabel : '',
				actionArr:[
					{
						img:'https://5b0988e595225.cdn.sohucs.com/images/20190910/fcf7a8cc00374260a675411d479fa2eb.jpeg',
						action: '6点30分上校车'
					},
					{
						img:'https://appimg.dzwww.com/share/2021/09/01/fd99138-b727d68_750.JPEG',
						action: '7点00分下校车'
					},
					{
						img:'https://img0.baidu.com/it/u=3725877095,1606976091&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						action: '7点05分刷卡进校'
					},
					{
						img:'https://img2.baidu.com/it/u=2701533473,1086974021&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422',
						action: '7点10分饭堂就餐'
					},
					{
						img:'https://img2.baidu.com/it/u=1705957018,898559961&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						action: '7点30分教学楼门口'
					},
					{
						img:'https://img2.baidu.com/it/u=3700821373,3122468605&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						action: '12点20分进入宿舍'
					},
					{
						img:'https://img1.baidu.com/it/u=1977047086,1043041267&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667',
						action: '13点20分离开宿舍'
					},
					{
						img:'https://img2.baidu.com/it/u=1705957018,898559961&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						action: '14点00分教学门口'
					},
					{
						img:'https://img0.baidu.com/it/u=3725877095,1606976091&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500',
						action: '17点00分教学打卡'
					},
				
				],
				// leftActionArr: [],
				// rightActionArr: [],
				
			}
		},
		computed:{
			leftActionArr(){
				return this.actionArr.filter((item,index)=>{ return index%2 == 1 })
			},
			rightActionArr(){
				return this.actionArr.filter((item,index)=>{ return index%2 == 0 })
			}
		},
		components:{
		},
		methods: {
			handleSubmit(){
				if(!this.params.startDate) return this.setMessage('请选择有效开始时间')
				if(!this.params.endDate) return this.setMessage('请选择有效结束时间')
				acTemporaryGeneralAddApi(this.params).then(res=>{
						this.setMessage('操作成功')
				})
			},
			handleDetail(item){
				this.goPage('/pages/componentsC/safe/accessRecordDetail',{id:1})
			},
			scrolltolower(){
				if(this.total == this.list.length){
					return this.setMessage('没有更多了')
				}
				this.params.currPage ++
				this.getList()
			},
			goSearch(){
				if(this.params.startDate && this.params.endDate ){
					if(new Date(this.params.startDate) > new Date(this.params.endDate) ) return this.setMessage('开始时间不能大于结束时间')
				}
				this.params.currPage = 1 
				this.getList()
			},
			startDateConfirm(e){
				let date = this.dateformat(e.value)
				this.params.startDate = date
				console.log(this.params.startDate);
				this.startDateShow = false
			},
			endDateConfirm(e){
				let date = this.dateformat(e.value)
				this.params.endDate = date
				this.endDateShow = false
			},
			getList(){
				let params = this.params
				if(!params.endDate) delete params.endDate
				if(!params.startDate) delete params.startDate
				if(!params.transChannl) delete params.transChannl
				acAccessRecordApi(params).then(res=>{
					if(params.currPage==1) this.list = []
					this.list = this.list.concat(res.page.list)
					this.total = res.page.totalCount
				})
			},
			goSearch(){
				this.params.currPage = 1
				this.getList()
			}
			
		},
		onLoad() {
			// let info = uni.getStorageSync('selectInfoAccount')
			// this.getList()
		},
		onShow() {
			
		},
	}
</script>

<style lang="scss" scoped>
.page{
	background-color: #f1f1f1;
	// height: 100vh;
	.searchBox{
		display: flex;
		align-items: center;
		background-color: #fff;
		padding: 0 20rpx;
		border-bottom: 1px solid #f1f1f1;
		margin: 20rpx;
		border-radius: 8rpx;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		.inputBox{
			flex: 1;
			padding-right: 30rpx;
			.inputRow{
				height: 80rpx;
				display: flex;
				align-items: center;
				font-size: 32rpx;
				padding-left: 20rpx;
				.label{
					color: #191919;
					margin-right: 30rpx;
				}
			}
			.input{
				
			}
			.emty{
				color: #c0c4cc;
			}
			.val{
				
			}
		}
		.btnBox{
			display: flex;
			flex-direction: column;
			padding: 10rpx 0;
			.reset{
				margin-top: 20rpx;
				border: 1px solid #f1f1f1;
				background: #fff !important;
				color: #353535 !important;
			}
			.btn{
				padding: 0 30rpx;
				// width: 110rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: #1890ff;
				border-radius: 8rpx;
				color: #fff;
			}
		}
	}
	
	.submitBtn{
		margin: 40rpx;
		// width: 110rpx;
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #1890ff;
		border-radius: 8rpx;
		color: #fff;
	}
	
	.contentBox{
		display: flex;
		box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.16);
		background: #fff;
		margin: 20rpx;
		height: 100%;
		padding: 20rpx;
		border-radius: 8rpx;
		// width: 95%;
		.itemBox{
			width: 50%;
			padding: 10rpx;
		}
		.left{
			border-right: 1px solid #f1f1f1;
		}
		.right{
			margin-top: 80rpx;
		}
		.leftRow{
			display: flex;
			align-items: center;
			height: 160rpx;
		}
		.rightRow{
			display: flex;
			justify-content: flex-end;
			align-items: center;
			height: 160rpx;
		}
		.text{
			flex:1;
			margin: 10rpx;
		}
	}
}
</style>
